begin tran
declare @i int 
select @i = 0
create table #temp (fg_pick_no nvarchar(20))
while(@i<100)
begin
 
declare @p7 nvarchar(20), @key int
exec sp_gen_note2 N'KO-IS',N'fg_pick_hdr',N'fg_pick_no',@p7 output

exec sp_fg_dir_pick_hdr_save @p7,N'',N'',N'2013/08/03',N'2013/08/03',N'KO',N'OUT',N'N',N'KOTB',N'',N'KOYO',N'igsadmin'
select @key = key_ind from fg_pick_hdr where fg_pick_no=@p7
insert igs_status_chg_log(tbl_name, key_value, status, set_date, set_by, set_level, cur_status,user_grp) 
values(N'fg_pick_hdr',@key,N'G',getdate(),N'igsadmin','999','F','IGSADMIN')      
insert into #temp select @p7

select @i = @i+1
end
select *from #temp
rollback tran